package com.test32_网络编程.udp.server;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UDPServer {

    public static void main(String[] args) throws Exception {
        DatagramSocket server = new DatagramSocket(8000);   // 设置服务器端的端口
        String message = "www.yootk.com";   // 当前要发送的数据内容
        DatagramPacket packet = new DatagramPacket(message.getBytes(), 0, message.length(),
                InetAddress.getByName("localhost"), 9999);  // 创建数据报
        server.send(packet);    // 发送数据报
        System.out.println("【UDPServer】数据信息发送完毕......");
        server.close();
    }
}
